package lab02.test25;

import java.util.Scanner;

public class Test25 {
    public static void main(String[] args) {

        //从键盘录入两个数
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入第一个数：a=");
        int a = sc.nextInt();
        System.out.println("请输入除数：b=");
        int b = sc.nextInt();

        //0不能作为除数的异常处理
        try {
            int result = a / b;
            System.out.println("result="+result);
        } catch (ArithmeticException e) {
            System.out.println("0不能作为除数");
            e.printStackTrace();
        } catch (Exception e) {
            System.out.println("0不能作为除数");
            e.printStackTrace();
        }

    }
}
